<?php

namespace App\Console\Commands\Cron;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;

class TestCastCron extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @example php artisan cron:testCast jobCast --relation=jobProd
     * @var string
     */
    protected $signature = 'cron:testCast {cast} {--relation=}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'run crontab for testCast';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        $cast = $this->argument('cast'); // 必传参数，不指定参数名的情况下用argument
        $relation = $this->option('relation'); // 非必传参数，用--开头指定参数名
        $msg = date('[Y-m-d H:i:s]')." your params : cast : {$cast}, relation : {$relation}";
        Log::channel('cron')->info($msg);
        echo $msg;
        return 0;
    }
}
